package com.example.design.shejimoshi.action.visitor.practice2;

import com.example.design.shejimoshi.action.visitor.practice2.element.CardStatusResource;
import com.example.design.shejimoshi.action.visitor.practice2.visit.EditCardStatusVisitor;
import com.example.design.shejimoshi.action.visitor.practice2.visit.Visitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Description 基于Spring
 * @Author liuzhihui
 * @Date 2024/6/27
 */
@Component
public class VisitorSpring {

    /**
     * 需要再写一个类编排CardStatusResource，Map的key为operatorId，value为CardStatusResource
     */
    @Resource
    Map<String, CardStatusResource> CardStatusResourceMap;

    /**
     * 业务代码
     */
    public void bisiness(String operatorId) {
        CardStatusResource cardStatusResource = CardStatusResourceMap.get(operatorId);
        Visitor editCardStatusVisitor = new EditCardStatusVisitor();
        cardStatusResource.accept(editCardStatusVisitor);
    }

}
